
	<resultMap id="BaseResultMap" type="<%=props.packageName%>.<%-props.entityPackage%>.<%-tb.className%>" ><%
	tb.fields.sort((a,b)=>{
		if(a.COLUMN_KEY=='PRI')return -1;
		if(b.COLUMN_KEY=='PRI')return 1;
		return 0;
	});
	tb.fields.forEach(field=>{
        var tag=field.COLUMN_KEY=='PRI'?'id':'result';
    %>
        <<%-tag%> column="<%-field.COLUMN_NAME%>" property="<%-under2Camel(field.COLUMN_NAME)%>" jdbcType="<%-toJdbcType(field.DATA_TYPE)%>" />
        <%});%>
    </resultMap>

<%
	
	//计算本表引用的情况：
	var associations = tb.fields.filter(field=>field.REFERENCED).map(field=>{
		 return {
			tagetClass:`${props.packageName}.${props.mapperPackage}.${under2Pascl(field.REFERENCED.TABLE_NAME)}Mapper.findByPrimaryKey`,
			property:under2Camel(field.REFERENCED.TABLE_NAME),
			column:field.COLUMN_NAME
		}
	});

	var collections = [];
	tb.fields.filter(field=>field.BE_REFERENCED).forEach(field=>{
		field.BE_REFERENCED.forEach(bf=>{

			collections.push( {
				tagetClass:`${props.packageName}.${props.mapperPackage}.${under2Pascl(bf.TABLE_NAME)}Mapper.findBy${under2Pascl(bf.COLUMN_NAME)}`,
				property:under2Camel(bf.TABLE_NAME)+props.listName,
				column:field.COLUMN_NAME
			});

		});
		 
	});

%>


     <resultMap  type="<%=props.packageName%>.<%-props.entityPackage%>.<%-tb.className%>" id="CasCadeResult" >
    	<%tb.fields.forEach(field=>{
        var tag=field.COLUMN_KEY=='PRI'?'id':'result';
    %>
        <<%-tag%> column="<%-field.COLUMN_NAME%>" property="<%-under2Camel(field.COLUMN_NAME)%>" jdbcType="<%-toJdbcType(field.DATA_TYPE)%>" />
        <%});%>
    	<%associations.forEach(item=>{
    	%>
    	<association property="<%-item.property%>" select="<%-item.tagetClass%>" column="<%-item.column%>"></association>
    	<%
    	})%>
    	<%collections.forEach(item=>{
    	%>
    	<collection property="<%-item.property%>" select="<%-item.tagetClass%>" column="<%-item.column%>">		</collection>
 		<%
    	})%>
    </resultMap>